//app.js
const API = require('/api/base')
const vPush = require('/api/vpush')
const miniShopPlugin = requirePlugin('mini-shop-plugin');
App({
  datalist: {},
  vPush: new vPush(API.getHost()),
  recorderManager: wx.getRecorderManager(),
  backgroundAudioManager: wx.getBackgroundAudioManager(),

  onLaunch: function() {
    miniShopPlugin.initApp(this, wx);
    miniShopPlugin.initHomePath('/pages/shop/shop');
    let advert=wx.getStorageSync('advert')
    if(advert)
    {
      this.globalData.advert=advert
    }
    API.login()
    API.template();
    wx.getSystemInfo({
      success: e => {
        this.globalData.isIphoneX=e.model.match(/iPhone X/gi)
        this.globalData.StatusBar = e.statusBarHeight;
        let capsule = wx.getMenuButtonBoundingClientRect();
        if (capsule) {
          this.globalData.Custom = capsule;
          this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
        } else {
          this.globalData.CustomBar = e.statusBarHeight + 80;
        }
      }
    })
  },
  modalTip: function(t) {
    var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 2500;
    wx.showToast({
      title: t,
      icon: "none",
      mask: !0,
      duration: e
    });
  },
  showLoading: function() {
    var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "加载中...";
    wx.showLoading({
      title: t,
      mask: !0,
      success: function(t) {}
    });
  },

  onShow: function() {
    if (wx.getStorageSync('scope')) {
      this.globalData.user = API.getUser();
    }
    if (wx.getStorageSync('message')) {
      this.globalData.message = wx.getStorageSync('message');
    }
    if (wx.getStorageSync('templates')) {
      this.globalData.templates = wx.getStorageSync('templates');
    }
  },
  scrollEndTime: 250,

  globalData: {
    isIphoneX:'',
    user: '',
    message: '',
    templates: '',
    advert:'',
  }

})
